function performSearch() {

    const searchInput = document.getElementById('search-input');
     const searchForm = document.getElementById('search-form');
    const resultsList = document.getElementById('search-results-list');
    const searchKeyword = searchInput.value;
    
    if (searchKeyword) {
        window.location.href = `search.html?keyword=${encodeURIComponent(searchKeyword)}`;
    }
   
    searchForm.addEventListener('submit', function(e) {
        e.preventDefault(); // 阻止表单默认提交行为

        const keyword = searchInput.value;
        if (!keyword) {
            alert('请输入搜索关键词');
            return;
        }

        // 发送 axios 请求
        axios.post('/search', { keyword: keyword })
            .then(response => {
                // 处理响应数据
                resultsList.innerHTML = ''; // 清空现有结果

                if (response.data.length === 0) {
                    resultsList.innerHTML = '<li>没有找到相关结果</li>';
                } else {
                    response.data.forEach(item => {
                        const li = document.createElement('li');
                        li.innerHTML = `
                            <img src="${item.image}" alt="产品图片">
                            <div class="product-content">
                                <div class="product-title">${item.name}</div>
                                <div class="product-description">${item.description}</div>
                                <div class="product-price">价格：¥${item.price}</div>
                                <a href="#" class="product-button">查看详情</a>
                            </div>
                        `;
                        resultsList.appendChild(li);
                    });
                }
            })
            .catch(error => {
                // 处理错误
                alert('搜索出错: ' + error.message);
            });
    });
}